package com.chenjj.scala.bibao

import com.chenjj.scala.bibao.BiBao.{addInt, loopThrough,result}

object Main {

  def main(args: Array[String]): Unit = {
    //测试闭包
    loopThrough(10){addInt}
    println(result)

    result = 0 //这里如果不对result初始化，后面得计算结果将基于前面得结果计算
    loopThrough(5){addInt}
    println(result)

    var product=1
    loopThrough(4){product *= _} // 1*2*3*4
    println(product)
  }
}
